import { http } from "@/utils/http";

export type ResultType = ReplaceTargetType<any[] | any>;

export const getTree = (params) => {
  return http.request<ResultType>({
    url: "/kgManagerApi/kg-manager/model/kg-category/tree/lazy",
    method: "get",
    params: params,
  });
};

export const addSub = (row) => {
  return http.request<any>({
    url: "/kgManagerApi/kg-manager/model/kg-category/add/same/level",
    method: "post",
    data: row,
  });
};

export const addSon = (row) => {
  return http.request<any>({
    url: "/kgManagerApi/kg-manager/model/kg-category/add/sub/level",
    method: "post",
    data: row,
  });
};

export const addTopNode = (row) => {
  return http.request<any>({
    url: "/kgManagerApi/kg-manager/model/kg-category/add/top/level",
    method: "post",
    data: row,
  });
};

export const remove = (id) => {
  return http.request<any>({
    url: "/kgManagerApi/kg-manager/model/kg-category/delete",
    method: "delete",
    params: {
      id,
    },
  });
};

export const removeValidate = (id) => {
  return http.request<any>({
    url: "/kgManagerApi/kg-manager/model/kg-category/delete/validate",
    method: "delete",
    params: {
      id,
    },
  });
};

export const rename = (row) => {
  return http.request<any>({
    url: "/kgManagerApi/kg-manager/model/kg-category/rename",
    method: "post",
    data: row,
  });
};

export const download = () => {
  return http.request<any>({
    url: "/kgManagerApi/kg-manager/model/kg-category/export/excel",
    method: "get",
    responseType: "blob",
  });
};
